package com.tro.common.util.office;

import java.util.List;
import java.util.Map;

import com.tro.common.util.string.StringUtlis;

public class OfficeUtil {
	public static String toHtml(String fileName,String basePath,String imgPath){
		String result="ERROR_DOC";
		if(fileName.toLowerCase().endsWith(".doc")){
			Map<String,Object> re=DocToHtml.docToHtmlRMap(fileName, basePath, imgPath);
			result=re.get("html").toString();
			//替换照片
			List<String> files=(List)re.get("imgs");
			for(String f:files){
				result=result.replace(f, imgPath.replace(basePath, "")+f);
			}
		}else if(fileName.toLowerCase().endsWith(".docx")){
			result=DocXToHtml.docxToHtml(fileName, basePath, imgPath);
		}else if(fileName.toLowerCase().endsWith(".xls")){
			result=XlsToHtml.xlsToHtml(fileName, basePath);
		}else if(fileName.toLowerCase().endsWith(".xlsx")){
			//result=XlsXToHtml.xlsxToHtml(fileName, basePath);
		}else if(fileName.toLowerCase().endsWith(".ppt")){
			result=pptToHtml.pptToHtml(fileName, basePath, imgPath);
		}else if(fileName.toLowerCase().endsWith(".pptx")){
			result=pptXToHtml.pptxToHtml(fileName, basePath, imgPath);
			
		}else{
			
		}
		result=StringUtlis.cleanHtml(result);
		return result;
	}
}
